# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=acorn
pkgver=8.10.0
epoch=1
pkgrel=1
pkgdesc='A tiny, fast JavaScript parser, written completely in JavaScript.'
arch=('any')
url='https://github.com/acornjs/acorn'
license=('MIT')
depends=('nodejs')
makedepends=('npm')
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('174480999f2252d4bffe6f039824c0d23961e930ca9074322bac5ce95e0a0d3c99280f5d9ef5fdff7b114d542b5a6efd82550065b9e698d71d6305081d65726f')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  mkdir -p "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "../../../lib/node_modules/$pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/"
}
